# 元组，不能被修改的列表; 是指不能修改其中的数据被分配的内存地址

# example1, 修改了内存地址，所以不能被修改

# data = (11, 42, 52, 74, 8568, 23, 48, 24, 646, 7757)
# print(data)
# index = 0
# while index < len(data):
#     print(id(data[index]))
#     index +=1

# try:
#   data[2]=0
# except TypeError as e:
#     print(f"发生错误：{e}")

# print(data)
# index = 0
# while index < len(data):
#     print(id(data[index]))
#     index +=1


# example2, 内存地址不变

data2 = (11, 42, [52, 74, 8568], 23, 48, 24, 646, 7757)

index = 0
while index < len(data2):
    print(id(data2[index]))
    index += 1

data2[2][1] = 0
print(data2)

index = 0
while index < len(data2):
    print(id(data2[index]))
    index += 1

# example3 ，相同值的数据，不是同一数据
print("==========example3==========")

index = 0
while index < len(data2):
    print(id(data2[index]))
    index += 1

samevalue = [52, 74, 8568]
print(f"id of samevalue", id(samevalue))

try:
    data2[2] = samevalue
except TypeError as e:
    print(f"error of example3", e)
